﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <script>
        //九九乘法表
        //for (var i = 1; i < 10; i++) {
        //    let num = ` `;
        //    for (var j = 1; j <= i; j++) {
        //       num=num+ (` ${i}*${j}=` + i * j );
        //    } console.log(num);
        //}

        //while100求和
        //let k = 0;
        //let sum = 0;
        //while (k < 101) {
        //    sum = sum + k;
        //    k++;
        //}
        //console.log(sum);

        //do while 100求和
        //do {
        //    sum = sum + k;
        //    k++;
        //} while (k < 101);
        //console.log(sum);

        //数组最大值
        //let arr = [2, 6, 6, 1, 77, 52, 25, 7, 7];
        //let max = 0;
        //for (var i = 0; i < arr.length; i++) {
        //    if (arr[i] > max) {
        //        max = arr[i];
        //    }
        //}
        //console.log(max);

        //数组的求和，平均数
        //let arr = [2, 6, 6, 1, 77, 52, 25, 7, 7];
        //let sum = 0;
        //for (var i in arr) {
        //    sum = sum + arr[i]
        //}
        //console.log(sum, sum / arr.length);

        //筛选大于10
        //let arr = [2, 6, 6, 1, 77, 52, 25, 7, 7];
        //let arr1 = [];
        //let j = 0;
        //for (var i in arr) {
        //    if (arr[i] > 10) {
        //        arr1[j++] = arr[i];
        //    }
        //}
        //console.log(arr1);

        //删除数组中的奇数
        //let arr = [2, 6, 6, 1, 77, 52, 25, 7, 7];
        //let arr1 = [];
        //let j = 0;
        //for (var i in arr) {
        //    if (arr[i] % 2 == 0) {
        //        arr1[j++] = arr[i];
        //    }

        //}
        //arr = arr1
        //console.log(arr);

        //反转元素 放入新的数组
        //let arr = [2, 6, 6, 1, 77, 52, 25, 7, 7];
        //let arr1 = [];
        //for (var i = 0; i < arr.length; i++) {
        //    arr1[i] = arr[(arr.length - 1) - i];
        //}
        //console.log(arr1);

        //数组去重复 形成新的数组
        //let arr = [2, 6, 6, 1, 77, 52, 25, 7, 7, ];
        //let arr1 = [];
        //let k = 0;
        //for (var i = 0; i < arr.length; i++) {
        //    for (var j = i; j < arr.length; j++) {
        //        if (arr[i] == arr[j] && j != i) {
        //            break;
        //        } else if (j == arr.length - 1) {
        //            arr1[k++] = arr[i];
        //        }
        //    }
        //}
        //console.log(arr1);

        //数组转化为字符串
        //var arr = [2, 6, 6, 1, 77, 52, 25, 7, 7, ];
        //let result = `[`;
        //for (var i in arr) {
        //    if (i == arr.length - 1) {
        //        result = `${result}'${arr[i]}'`;
        //    } else {
        //        result = `${result}'${arr[i]}', `;
        //    }
        //}
        //result = `${result}]`;
        //console.log(result);

        //数组的排序
        //let arr = [2, 6, 6, 1, 77, 52, 25, 7, 7, ];
        //let num = 0;
        //for (var i = 0; i < arr.length; i++) {
        //    if (arr[i] > arr[i + 1]) {
        //        num = arr[i];
        //        arr[i] = arr[i + 1];
        //        arr[i + 1] = num;
        //        i = -1;
        //    }
        //} console.log(arr);
    </script>
</body>
</html>